<?php

namespace app\common\model\store;

use app\common\model\BaseModel;

/**
 * 激活记录模型
 * Class ShopActivation
 * @package app\common\model\store
 */
class ShopActivation extends BaseModel
{
    protected $name = 'store_shop_activation';


    /**
     * 关联用户表
     * @return \think\model\relation\BelongsTo
     */
    public function user()
    {
        $module = self::getCalledModule() ?: 'common';
        return $this->belongsTo("app\\{$module}\\model\\User");
    }

    /**
     * 关联培训机构
     * @return \think\model\relation\HasOne
     */
    public function shop()
    {
        $module = self::getCalledModule() ?: 'common';
        return $this->belongsTo("app\\{$module}\\model\\store\\Shop");
    }


    /**
     * 记录详情
     * @param $id
     * @return static|null
     * @throws \think\exception\DbException
     */
    public static function detail($id)
    {
        return static::get($id, ['user','shop']);
    }

}